Skip to content

Python 3.12 compatibility#58

Draft
timbernat wants to merge 8 commits into
mainfrom
py312-updates
Draft

Python 3.12 compatibility#58
timbernat wants to merge 8 commits into
mainfrom
py312-updates

Conversation

@timbernat
Copy link
Copy Markdown
Owner

@timbernat timbernat commented Apr 29, 2026

Description

Update package code and build config to allow use with Python 3.12+ as Python 3.11 enters end-of-life.

Todos

Notable points that this PR has either accomplished or will accomplish.

  • Enable pip install polymerist without dependency conflicts in envirnment with at least Python 3.12
  • Update with minimal changes to source, and without breaking examples
  • Resolve Support for Python 3.12 #57

Questions

  • What are sources of 3.12 incompatibility?
    • In-code (e.g. typehints, which did change)
      • _importlib.resources.common.get_package deprecation
    • Dependency (e.g. importlib, OpenFF)
      • mBuild (a lot actually, including np.vecdot deprecation, pkg_resources, and mbuild.plugins)
    • Other?

Status

  • Confirm import across all subpackages
  • Verify CI workflow runs w/ 3.12 added to matrix
  • Check compat on PyPI (dev) release
  • Ready to go

@timbernat timbernat self-assigned this Apr 29, 2026
@timbernat timbernat added the priority:medium Moderate urgency, issue has major impacts on some but not most parts of the codebase label Apr 29, 2026
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timbernat
Copy link
Copy Markdown
Owner Author

@joelaforet, combing through I've made headway in some places but run into problems on others. Diving into the leads given in #58, the specific break was due to deprecation of importlib.resources._common.get_package(), which was harder than expected to find in the changelog but I eventually tracked down the commit, from as far back as 10/2022! The prior get_package() functionality was replaceable with a check for the submodule_search_locations return value from the module's spec, which is compatible with both 3.11 and 3.12, requiring only _common.resolve imported. I've confirmed this fix is backward-compatible between 3.11 and 3.12 against the tests for pkginspect.

As far as other dependencies, mBuild seems to be causing an inordinate amount of issues, including:

  • GMSO requiring pkg_resources (documented in CI fail, likely due to setuptools<82.0 unpin)
  • Missing mbuild.plugins internal dependency (this CI fail)
  • Deprecation errors from within mbuild on a np.vecdot import, through I haven't been able to reproduce this consistently.

There also seems to be some sensitivity to installation order, i.e. whether pip-installing polymerist then installing mbuild and or creating an env from a conda.yml and pip-installing afterwards. Digging into that more will take time and might require some extra eyes, but I'm hoping resolving that will be the trickiest blocker to getting 3.12 support in. It's not clear to me as-writing where other incompatibilities may lie; for now, I've removed all upper version pins in the shipped env .ymls and will add them back in if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Moderate urgency, issue has major impacts on some but not most parts of the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Python 3.12

2 participants